/*
 * Created on Jun 14, 2005
 *
 */
package com.erclab.internal.xpresso.handlers;

import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.ArrayList;

import org.apache.commons.dbutils.ResultSetHandler;

import com.erclab.internal.xpresso.options.Option;
import com.erclab.internal.xpresso.security.User;

/**
 * @author Enrique Rodriguez.
 *
 */
public class OptionsHandler implements ResultSetHandler {

	private User user;

	public OptionsHandler(User user){
		this.user = user;
	}

	/* (non-Javadoc)
	 * @see org.apache.commons.dbutils.ResultSetHandler#handle(java.sql.ResultSet)
	 */
	public Object handle(ResultSet rs) throws SQLException {
		ArrayList options = new ArrayList();
		while (rs.next()){
			Option op = new Option();
			op.setIdOption(rs.getInt("IdOption"));
			op.setLink(rs.getString("Link"));
			op.setOptionText(rs.getString("OptionText"));
			op.setStyle(rs.getString("Style"));
			op.setImage(rs.getString("Image"));
			
			// Here we could implement a security check to see if the user can see
			// this option or not before adding it to the arraylist.
			
			options.add(op);
		}
		return options;
	}

}
